﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using UI.WebPage.Background;
using Model.Cms;
using BLL.Cms;
using Com.Ompchina.Lib.Net;
namespace Com.Ompchina.Web.admin.cms
{
    public partial class list_node : ListInfoPage, IListInfo
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && PageAction.Equals("list")) this.InitParameter();
            if (!IsPostBack && PageAction.Equals("delete")) this.ExecuteUpdate();
        }

        #region IListInfo 成员

        public void InitParameter()
        {
            ddlTerm.DefaultSelect = RequestParam.GetString(Request, "termid");
        }

        public void ExecuteUpdate()
        {
            int id = RequestParam.GetInt(Request, "id");
            if (id > 0)
            {
                if (new NodeBLL().DeleteNode(id))
                    base.SetMessage(true, "删除成功，<a href='list_node.aspx?action=list'>点击返回</a>");
                else
                    base.SetMessage(false, "删除错误，<a href='list_node.aspx?action=list'>点击返回</a>");
            }
            else
                base.SetMessage(false, "请选择要删除的信息，<a href='list_node.aspx?action=list'>点击返回</a>");
        }

        #endregion

        #region 页面私有方法
        protected IList<NodeInfo> _GetNode(int pageSize, out int recordCount)
        {
            return new NodeBLL().BackList(int.Parse(ddlTerm.SelectedValue), PageIndex, pageSize, out recordCount);
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Redirect(string.Format("list_node.aspx?action=list&termid={0}"
                , Server.UrlEncode(ddlTerm.SelectedValue))
                , 0);
        }
        #endregion        

        
    }
}
